package com.iot.gateway.tsl.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;

/**
 * 调用开放平台获取 Token 的响应实体
 */
@Schema(name = "OpenTokenResponse", description = "获取 OpenToken 接口响应对象")
public class OpenTokenResponse {

    @Schema(description = "业务状态码；00-成功，01-失败")
    @JsonProperty("tx_code")
    private String txCode;

    @Schema(description = "错误信息，仅在失败时返回")
    @JsonProperty("error_info")
    private ErrorInfo errorInfo;

    @Schema(description = "返回的数据体，成功时包含 open_token")
    private Data data;

    public String getTxCode() {
        return txCode;
    }

    public void setTxCode(String txCode) {
        this.txCode = txCode;
    }

    public ErrorInfo getErrorInfo() {
        return errorInfo;
    }

    public void setErrorInfo(ErrorInfo errorInfo) {
        this.errorInfo = errorInfo;
    }

    public Data getData() {
        return data;
    }

    public void setData(Data data) {
        this.data = data;
    }

    @Schema(name = "ErrorInfo", description = "错误信息结构")
    public static class ErrorInfo {
        @Schema(description = "状态码", example = "01")
        private String code;
        @Schema(description = "错误消息", example = "签名校验失败")
        private String message;
        @Schema(description = "相关 URL", example = "http://...")
        private String url;

        public String getCode() {
            return code;
        }

        public void setCode(String code) {
            this.code = code;
        }

        public String getMessage() {
            return message;
        }

        public void setMessage(String message) {
            this.message = message;
        }

        public String getUrl() {
            return url;
        }

        public void setUrl(String url) {
            this.url = url;
        }
    }

    @Schema(name = "Data", description = "成功时返回的数据体")
    public static class Data {
        @Schema(description = "开放平台返回的 token")
        @JsonProperty("open_token")
        private String openToken;

        public String getOpenToken() {
            return openToken;
        }

        public void setOpenToken(String openToken) {
            this.openToken = openToken;
        }
    }
}
